package com.ibeetl.codestory.core.ast;

import com.ibeetl.codestory.core.type.Type;
import com.ibeetl.codestory.core.type.TypeName;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * 一个类的变量表
 */
@Data
public class VarTable  {
	Set<String> pkgs;
	ClassDeclareAst clazzAst;
	String packageName;
	Map<Ast, Map<String, TypeName>> vars = new HashMap<>();
	public VarTable(ClassDeclareAst clazzAst){
		this.clazzAst = clazzAst;
	}

	public void register(Ast blockAst,Type type ,String name){
		Map blockVar = vars.getOrDefault(blockAst,new HashMap<String, TypeName>());
		blockVar.put(name,new TypeName(type,name));
	}

}
